#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Instruments/Bonds/FloatingRateBond.h>
#pragma unmanaged 
#include <ql\instruments\bonds\btp.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Times;
using namespace Cephei::QL::Indexes;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Instruments { namespace Bonds {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICCTEU
	public ref class CCCTEU  : 
            public CFloatingRateBond,
            public Cephei::QL::Instruments::Bonds::ICCTEU
	{
	protected: 
		boost::shared_ptr<QuantLib::CCTEU>* _ppCCTEU;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CCTEU>* _phCCTEU;
#endif
		Object^ _CCTEUOwner;     // reference to object that manages the storage for this object
	internal:
		CCCTEU (DateTime maturityDate, Double spread, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Termstructures::IYieldTermStructure^>^ fwdCurve, Microsoft::FSharp::Core::FSharpOption<DateTime>^ startDate, Microsoft::FSharp::Core::FSharpOption<DateTime>^ issueDate, Cephei::QL::IPricingEngine^ QL_Pricer);
        CCCTEU (boost::shared_ptr<QuantLib::CCTEU>& childNative, Object^ owner);
        CCCTEU (QuantLib::CCTEU& childNative, Object^ owner);
        CCCTEU (CCCTEU^ copy);
        CCCTEU (PLATFORM::Type^ t);
#ifdef STRUCT
        CCCTEU (QuantLib::CCTEU childNative);
#endif       
#ifdef HANDLE
		CCCTEU (QuantLib::Handle<QuantLib::CCTEU>& childNative, Object^ owner);
		CCCTEU (QuantLib::Handle<QuantLib::CCTEU> childNative);
#endif
		virtual ~CCCTEU ();
		!CCCTEU ();

	internal:
		QuantLib::CCTEU& GetReference ();
		boost::shared_ptr<QuantLib::CCTEU>& GetShared ();
		QuantLib::CCTEU* GetPointer ();
        void SetCCTEU (boost::shared_ptr<QuantLib::CCTEU> native)
        {
            if (_ppCCTEU != NULL)
                delete _ppCCTEU;
            _ppCCTEU = new boost::shared_ptr<QuantLib::CCTEU> (native);
            SetFloatingRateBond (boost::dynamic_pointer_cast<QuantLib::FloatingRateBond> (*_ppCCTEU));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CCTEU>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double AccruedAmount (Microsoft::FSharp::Core::FSharpOption<DateTime>^ d) ;
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Instruments::Bonds::ICCTEU^>::typeid)]
	[FactoryFor(Cephei::QL::Instruments::Bonds::ICCTEU::typeid)]
	[FactoryFor(Cephei::QL::Instruments::Bonds::ICCTEU_Factory::typeid)]
	public ref class CCCTEU_Factory sealed : public ICCTEU_Factory
	{
	public:
        virtual ICCTEU^ Create (DateTime maturityDate, Double spread, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Termstructures::IYieldTermStructure^>^ fwdCurve, Microsoft::FSharp::Core::FSharpOption<DateTime>^ startDate, Microsoft::FSharp::Core::FSharpOption<DateTime>^ issueDate, Cephei::QL::IPricingEngine^ QL_Pricer);
    };
   
/*Cephei*/ } /*QL*/ } /*Instruments*/ } /*Bonds */}
